module KindDom

  # The foundation of an object proxy is the BlankSlate.
  #
  # BlankSlate is included with Rails ActiveSupport
  # as active_support/vendor/builder-2.1.2/blankslate.rb
  #
  # From the Rails rdoc: "BlankSlate provides an abstract base class with 
  # no predefined methods (except for __send__ and __id__). BlankSlate is useful
  # as a base class when writing classes that depend upon method_missing 
  # (e.g. dynamic proxies)."
  #
  # ObjectProxy is a bare-bones proxy. Override #method_missing in your subclass
  # to handle method calls in the proxy.
  #
  class ObjectProxy < BlankSlate
  
    # Create a proxy to the provided object.
    def initialize(target)
      @target = target
    end
  
    # Override #method_missing in your subclass
    # to handle method calls in the proxy; call `super(sym, *args, &block)`
    # therein to get a response from the proxied object.
    def method_missing(sym, *args, &block)
      @target.__send__(sym, *args, &block)
    end
  end
  
end